using System;

namespace csammisrun.OscarLib
{
  /// <summary>
  /// Describes the potential errors the AOL servers can report during login
  /// </summary>
  public enum LoginErrorCode
  {
    /// <summary>
    /// The authorization server cannot be reached
    /// </summary>
    /// <remarks>This is the first server to which OSCAR clients connect.  The first thing to check if this
    /// error code is received is to ensure that your network is functioning correctly. After that, it's AOL's fault.</remarks>
    CantReachAuthServer,
    /// <summary>
    /// The Basic OSCAR Service server cannot be reached
    /// </summary>
    /// <remarks>This is the server to which a client is redirected after successful authentication. Failure to connect
    /// to the BOS server is due to an OSCAR service outage.  Note that there are many BOS servers; some screennames may
    /// be able to connect when others cannot.</remarks>
    CantReachBOSServer,
    /// <summary>
    /// The screenname is unrecognized or not in a format recognized by OSCAR, or the password does not match the screenname
    /// </summary>
    /// <remarks>The OSCAR server could send either this or <see cref="IncorrectScreennamePassword"/> to indicate a bad username and/or password</remarks>
    InvalidScreennamePassword,
    /// <summary>
    /// A necessary OSCAR service is unavailable
    /// </summary>
    ServiceUnavailable,
    /// <summary>
    /// The server has experienced an unknown error
    /// </summary>
    UnknownError,
    /// <summary>
    /// The screenname is unrecognized or not in a format recognized by OSCAR, or the password does not match the screenname
    /// </summary>
    /// <remarks>The OSCAR server could send either this or <see cref="InvalidScreennamePassword"/> to indicate a bad username and/or password</remarks>
    IncorrectScreennamePassword,
    /// <summary>
    /// The client sent incorrect authorization sequences
    /// </summary>
    BadAuthorizationInfo,
    /// <summary>
    /// The account has become invalidated
    /// </summary>
    AccountInvalid,
    /// <summary>
    /// The AOL admins have deleted the account
    /// </summary>
    AccountDeleted,
    /// <summary>
    /// The account has expired
    /// </summary>
    AccountExpired,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    DatabaseNoAccess,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    ResolverNoAccess,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    ResolverBadStatus,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    InternalError,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    ServiceOffline,
    /// <summary>
    /// The account has been suspended for activity against the Terms of Service
    /// </summary>
    AccountSuspended,
    /// <summary>
    /// The AOL admins have started reading your mail and realized you're &lt; 13 years old in real life
    /// </summary>
    AccountSuspendedBecauseOfAge,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    DatabaseSendError,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    DatabaseLinkError,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    DatabaseInvalidFields,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    DatabaseBadStatus,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    ReservationMapError,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    ReservationLinkError,
    /// <summary>
    /// The server has experienced an internal error
    /// </summary>
    ReservationTimeout,
    /// <summary>
    /// Too many accounts are logged in from the same external IP address
    /// </summary>
    TooManyUsersFromIP,
    /// <summary>
    /// The account has attempted to log in too frequently in a span of time
    /// </summary>
    RateLimitExceeded,
    /// <summary>
    /// The account's warning level is too high to allow login
    /// </summary>
    WarningLevelTooHigh,
    /// <summary>
    /// The client is using an outdated version of the ICQ protocol
    /// </summary>
    OldICQVersion,
    /// <summary>
    /// The ICQ number cannot be registered on the network
    /// </summary>
    CantRegisterICQ,
    /// <summary>
    /// An AOL admin account has provided an invalid SecurID for authentication
    /// </summary>
    InvalidSecurID
  }

  /// <summary>
  /// Describes the potential errors the AOL servers can report during an active session
  /// </summary>
  public enum ServerErrorCode
  {
    /// <summary>
    /// A secondary service connection (chat, buddy icons, etc.) has been lost
    /// </summary>
    LostSecondaryConnection,
    /// <summary>
    /// The primary service connection has been lost
    /// </summary>
    LostBOSConnection,
    /// <summary>
    /// Malformed SNAC header
    /// </summary>
    InvalidSNACHeader,
    /// <summary>
    /// Malformed SNAC packet contents
    /// </summary>
    InvalidSNACFormat,
    /// <summary>
    /// The server cannot send messages as fast as the client is requesting them
    /// </summary>
    ServerRateLimited,
    /// <summary>
    /// The local client has been rate limited
    /// </summary>
    ClientRateLimited,
    /// <summary>
    /// The recepient of a message or request is not logged into the network
    /// </summary>
    ReceiverNotLoggedIn,
    /// <summary>
    /// A secondary service is not available
    /// </summary>
    RequestedServiceUnavailable,
    /// <summary>
    /// The requested secondary service does not exist
    /// </summary>
    RequestedServiceUnknown,
    /// <summary>
    /// The client sent a SNAC that is no longer supported
    /// </summary>
    ObsoleteSNAC,
    /// <summary>
    /// The client has reported during authentication that it does not support a given feature
    /// </summary>
    NotSupportedByClient,
    /// <summary>
    /// The server does not support the requested feature
    /// </summary>
    NotSupportedByServer,
    RefusedByClient,
    ReplyTooBig,
    ResponsesLost,
    RequestDenied,
    InsufficientRights,
    /// <summary>
    /// The server will not relay the message because the receiver has been blocked by the sender
    /// </summary>
    ReceiverBlocked,
    /// <summary>
    /// The server will not relay the message because the sender's warning level is too high
    /// </summary>
    SenderWarningTooHigh,
    /// <summary>
    /// The server will not relay the message because the receiver's warning level is too high
    /// </summary>
    ReceiverWarningTooHigh,
    UserUnavailable,
    NoMatch,
    ListOverflow,
    AmbiguousRequest,
    ServerQueueFull,
    /// <summary>
    /// Operation can't be performed while connected via AOL
    /// </summary>
    NotOnAOL,
    /// <summary>
    /// Received unsolicited chat room information
    /// </summary>
    UnrequestedChatRoomInformation,
    /// <summary>
    /// The server requested a function which OscarLib does not support
    /// </summary>
    OscarLibUnsupportedFunction,
    /// <summary>
    /// Client received an unknown SNAC family
    /// </summary>
    UnknownSNACFamily,
    /// <summary>
    /// Client received an unknown ICBM channel
    /// </summary>
    UnknownMessageChannel,
    /// <summary>
    /// Client received an unknown Rendezvous channel
    /// </summary>
    UnknownRendezvousChannel,
    /// <summary>
    /// Unknown error
    /// </summary>
    UnknownError,
    SSIItemNotFound,
    SSIItemAlreadyExists,
    SSICantAddItem,
    SSIItemLimitExceeded,
    SSIItemRequiresAuthorization
  }
}
namespace csammisrun.OscarLib.Utility
{
	/// <summary>
	/// Provides static methods for retrieving information about a variety of commands and constants
	/// </summary>
	class Definitions
	{
    /// <summary>
    /// Gets the meaning of an error code returned by the server or generated by OscarLib as a <see cref="ServerErrorCode"/> 
    /// </summary>
		public static ServerErrorCode GetServerErrorCode(ushort errorcode)
		{
      ServerErrorCode retval = ServerErrorCode.UnknownError;
			switch(errorcode)
			{
				case 0x0001: retval = ServerErrorCode.InvalidSNACHeader; break;
				case 0x0002: retval = ServerErrorCode.ServerRateLimited; break;
				case 0x0003: retval = ServerErrorCode.ClientRateLimited; break;
				case 0x0004: retval = ServerErrorCode.ReceiverNotLoggedIn; break;
				case 0x0005: retval = ServerErrorCode.RequestedServiceUnavailable; break;
				case 0x0006: retval = ServerErrorCode.RequestedServiceUnknown; break;
				case 0x0007: retval = ServerErrorCode.ObsoleteSNAC; break;
				case 0x0008: retval = ServerErrorCode.NotSupportedByServer; break;
				case 0x0009: retval = ServerErrorCode.NotSupportedByClient; break;
				case 0x000a: retval = ServerErrorCode.RefusedByClient; break;
				case 0x000b: retval = ServerErrorCode.ReplyTooBig; break;
				case 0x000c: retval = ServerErrorCode.ResponsesLost; break;
				case 0x000d: retval = ServerErrorCode.RequestDenied; break;
				case 0x000e: retval = ServerErrorCode.InvalidSNACFormat; break;
				case 0x000f: retval = ServerErrorCode.InsufficientRights; break;
				case 0x0010: retval = ServerErrorCode.ReceiverBlocked; break;
				case 0x0011: retval = ServerErrorCode.SenderWarningTooHigh; break;
				case 0x0012: retval = ServerErrorCode.ReceiverWarningTooHigh; break;
				case 0x0013: retval = ServerErrorCode.UserUnavailable; break;
				case 0x0014: retval = ServerErrorCode.NoMatch; break;
				case 0x0015: retval = ServerErrorCode.ListOverflow; break;
				case 0x0016: retval = ServerErrorCode.AmbiguousRequest; break;
				case 0x0017: retval = ServerErrorCode.ServerQueueFull; break;
				case 0x0018: retval = ServerErrorCode.NotOnAOL; break;
				default: retval = ServerErrorCode.UnknownError; break;
			}
			return retval;
		}

    /// <summary>
    /// Gets the meaning of an error code returned by the server as a <see cref="LoginErrorCode"/> 
    /// </summary>
		public static LoginErrorCode GetLoginErrorString(ushort errorcode)
		{
      LoginErrorCode retval = LoginErrorCode.IncorrectScreennamePassword;
			switch(errorcode)
			{
				case 0x0001: retval = LoginErrorCode.InvalidScreennamePassword; break;
				case 0x0002: retval = LoginErrorCode.ServiceUnavailable; break;
				case 0x0003: retval = LoginErrorCode.UnknownError; break;
				case 0x0004: retval = LoginErrorCode.IncorrectScreennamePassword; break;
				case 0x0005: retval = LoginErrorCode.IncorrectScreennamePassword; break;
				case 0x0006: retval = LoginErrorCode.BadAuthorizationInfo; break;
				case 0x0007: retval = LoginErrorCode.AccountInvalid; break;
				case 0x0008: retval = LoginErrorCode.AccountDeleted; break;
				case 0x0009: retval = LoginErrorCode.AccountExpired; break;
				case 0x000A: retval = LoginErrorCode.DatabaseNoAccess; break;
				case 0x000B: retval = LoginErrorCode.ResolverNoAccess; break;
				case 0x000C: retval = LoginErrorCode.DatabaseInvalidFields; break;
				case 0x000D: retval = LoginErrorCode.DatabaseBadStatus; break;
				case 0x000E: retval = LoginErrorCode.ResolverBadStatus; break;
				case 0x000F: retval = LoginErrorCode.InternalError; break;
				case 0x0010: retval = LoginErrorCode.ServiceOffline; break;
				case 0x0011: retval = LoginErrorCode.AccountSuspended; break;
				case 0x0012: retval = LoginErrorCode.DatabaseSendError; break;
				case 0x0013: retval = LoginErrorCode.DatabaseLinkError; break;
				case 0x0014: retval = LoginErrorCode.ReservationMapError; break;
				case 0x0015: retval = LoginErrorCode.ReservationLinkError; break;
				case 0x0016: retval = LoginErrorCode.TooManyUsersFromIP; break;
        case 0x0017: retval = LoginErrorCode.TooManyUsersFromIP; break;
				case 0x0018: retval = LoginErrorCode.RateLimitExceeded; break;
				case 0x0019: retval = LoginErrorCode.WarningLevelTooHigh; break;
				case 0x001A: retval = LoginErrorCode.ReservationTimeout; break;
				case 0x001B: retval = LoginErrorCode.OldICQVersion; break;
        case 0x001C: retval = LoginErrorCode.OldICQVersion; break;
				case 0x001D: retval = LoginErrorCode.RateLimitExceeded; break;
				case 0x001E: retval = LoginErrorCode.CantRegisterICQ; break;
				case 0x0020: retval = LoginErrorCode.InvalidSecurID; break;
				case 0x0022: retval = LoginErrorCode.AccountSuspendedBecauseOfAge; break;
			}
			return retval;
		}
	}
}
